﻿using nplJobsCommon.JobSeeker;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace nplJobsDAL.Delete
{
    //delete a job seeker language proficiencies by id
    public class DeleteJobSeekerLanguageProficiency : DataAccessBase
    {
        public bool lastJobSeekerLanguageProficiencyID;

        public JobSeekerLanguageProficiency JobSeekerLanguageProficiency { get; set; }

        public DeleteJobSeekerLanguageProficiency()
        {
            StoredProcedureName = StoredProcedure.Name.spDeleteJobSeekerLanguageProficiency.ToString();
        }

        public void Insert()
        {
            DeleteJobSeekerLanguageProficiencyDataParameters contactInsertDataParameters = new DeleteJobSeekerLanguageProficiencyDataParameters(this.JobSeekerLanguageProficiency);
            DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName);
            dbHelper.Parameters = contactInsertDataParameters.Parameters;
            object LastJobSeekerLanguageProficiencyID = dbHelper.RunScalar();

            if (LastJobSeekerLanguageProficiencyID != null)
                lastJobSeekerLanguageProficiencyID = (bool)LastJobSeekerLanguageProficiencyID;
        }
    }

    #region SQL parameters for JobSeeker Language Proficiency
    public class DeleteJobSeekerLanguageProficiencyDataParameters
    {
        private SqlParameter[] _parameters;
        public bool lastJobSeekerLanguageProficiencyID;

        public DeleteJobSeekerLanguageProficiencyDataParameters(JobSeekerLanguageProficiency jobSeekerLanguageProficiency)
        {
            this.JobSeekerLanguageProficiency = jobSeekerLanguageProficiency;
            Build();
        }

        private void Build()
        {
            SqlParameter[] parameters = 
                {
                    new SqlParameter("@ID", JobSeekerLanguageProficiency.ID),
                    new SqlParameter("@JobSeekerID", JobSeekerLanguageProficiency.JobSeekerID),
                    new SqlParameter("@LanguageID", JobSeekerLanguageProficiency.LanguageID),
                    new SqlParameter("@ProficiencyID", JobSeekerLanguageProficiency.ProficiencyID),
                    new SqlParameter("@LastJobSeekerID", lastJobSeekerLanguageProficiencyID){ Direction= System.Data.ParameterDirection.Output},
                };

            Parameters = parameters;
        }

        public JobSeekerLanguageProficiency JobSeekerLanguageProficiency { get; set; }

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }


    }
    #endregion
}
